<template>
  <div>
<div id="echartsDiv" style="width: 500px;height: 500px">

</div>
  </div>
</template>

<script>
export default {
  name: "EchartsDiv",
  mounted() {
    this.drawLine();
  },
  methods: {
    drawLine() {
      // 基于准备好的dom，初始化echarts实例
      var myEchart = this.$echarts.init(document.getElementById("echartsDiv"));

      // 指定图表的配置项和数据
      var option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
            axisTick: {
              alignWithLabel: true
            }
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            name: 'Direct',
            type: 'bar',
            barWidth: '60%',
            data: [10, 52, 200, 334, 390, 330, 220]
          }
        ]
      };

      // 使用刚指定的配置项和数据显示图表。
      myEchart.setOption(option);
    }
  }
}
</script>

<style scoped>
#echartsDiv{

  width: auto;
  height: auto;
}
</style>
